/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VentanaOperacionesCliente.java
 *
 * Created on 25/06/2010, 11:42:29 AM
 */

package CapaGrafica;

import CapaLogica.GestionResort;
import CapaDatos.Cliente;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import CapaPersistencia.ControladorCliente;
import CapaLogica.ComunicaCliente;
import java.util.Calendar;
import java.awt.Image;
import java.awt.Toolkit;
import java.util.GregorianCalendar;

/**
 *
 * @author Maria
 */
public class VentanaOperacionesCliente extends javax.swing.JFrame {
     private ControladorCliente control = new ControladorCliente();
    /** Creates new form VentanaOperacionesCliente */
    public VentanaOperacionesCliente() {
        initComponents();
        mostrarTabla();
        this.setSize(600,600);
    }
    private void mostrarTabla() {
        DefaultTableModel dm = new DefaultTableModel();
        dm.addColumn("Nombre");
        dm.addColumn("Apellido");
        dm.addColumn("Cedula");
        dm.addColumn("Sexo");
        dm.addColumn("Fecha Nacimiento");
        dm.addColumn("Estado Civil");
        dm.addColumn("Nacionalidad");
        dm.addColumn("Numero de reservas");
        ArrayList <Cliente> clientes = this.control.todosLosClientes();
        for (Cliente cliente : clientes) {
            Vector row = new Vector();
            GestionResort.getLosClientes().agregarElemento(cliente);
            row.add(cliente.getNombre());
            row.add(cliente.getApellido());
            row.add(cliente.getCedula().toString());
            row.add(cliente.getSexo());
            row.add(cliente.getFechaNac());
            row.add(cliente.getEdoCivil());
            row.add(cliente.getNacionalidad());
            row.add(cliente.getNumReservas());
            dm.addRow(row);
        }
        this.tablaClientes.setModel(dm);


    }

    private void mostrarCliente(String cedula) throws ParseException {
        Cliente clienteMostrar = this.control.buscarCliente(cedula);
        this.sCedula.setText(clienteMostrar.getCedula());
        this.sNombre.setText(clienteMostrar.getNombre());
        this.sApellido.setText(clienteMostrar.getApellido());
        this.sEdoCivil.setText(clienteMostrar.getEdoCivil());
        this.sUserName.setText(clienteMostrar.getUserName());
        this.sPassword.setText(clienteMostrar.getPassword());
        this.sNacionalidad.setText(clienteMostrar.getNacionalidad());
        this.sSexo.setText(clienteMostrar.getSexo());
        this.sTipoCliente.setText(clienteMostrar.getTipoCliente());
         SimpleDateFormat fechaFormato = new SimpleDateFormat("dd-MM-yyyy");
        java.util.Date fecha = fechaFormato.parse(clienteMostrar.getFechaNac());
        this.sFecha.setDate(fecha);
        this.sNumReservas.setText(String.valueOf(clienteMostrar.getNumReservas()));
    }
    public boolean menor_edad (String fecha)
     {
       Calendar c = new GregorianCalendar();
       String annio="";
       int annio2;

       annio2 = c.get(Calendar.YEAR);
       annio=annio+fecha.charAt(6)+fecha.charAt(7)+fecha.charAt(8)+fecha.charAt(9);

       if (annio2-Integer.parseInt(annio)<18)
         return false;
       else
       return true;
     }




    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        tablaClientes = new javax.swing.JTable();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jLnombre1 = new javax.swing.JLabel();
        sNombre = new javax.swing.JTextField();
        jLapellido1 = new javax.swing.JLabel();
        sApellido = new javax.swing.JTextField();
        jLCedula = new javax.swing.JLabel();
        sCedula = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        sEdoCivil = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        sSexo = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        sFecha = new com.toedter.calendar.JDateChooser();
        jLabel9 = new javax.swing.JLabel();
        sNacionalidad = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        sUserName = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        sPassword = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        sNumReservas = new javax.swing.JTextField();
        jLtipoCliente = new javax.swing.JLabel();
        sTipoCliente = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLnombre = new javax.swing.JLabel();
        nNombre = new javax.swing.JTextField();
        jLapellido = new javax.swing.JLabel();
        nApellido = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        nCedula = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        nEdoCivil = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        nSexo = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        nFecha = new com.toedter.calendar.JDateChooser();
        jLabel3 = new javax.swing.JLabel();
        nNacionalidad = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        nUserName = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        nPassword = new javax.swing.JPasswordField();
        jLtitulo = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        jLabel16 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Operaciones Clientes");
        setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        setLocationByPlatform(true);

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        tablaClientes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tablaClientes.setName("tablaClientes"); // NOI18N
        tablaClientes.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                tablaClientesMouseReleased(evt);
            }
        });
        tablaClientes.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tablaClientesKeyReleased(evt);
            }
        });
        jScrollPane2.setViewportView(tablaClientes);

        jScrollPane1.setViewportView(jScrollPane2);

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel2.setBackground(new java.awt.Color(0, 102, 153));
        jPanel2.setName("jPanel2"); // NOI18N

        jLnombre1.setText("Nombre:");
        jLnombre1.setName("jLnombre1"); // NOI18N

        sNombre.setName("sNombre"); // NOI18N

        jLapellido1.setText("Apellido:");
        jLapellido1.setName("jLapellido1"); // NOI18N

        sApellido.setName("sApellido"); // NOI18N

        jLCedula.setText("Cedula:");
        jLCedula.setName("jLCedula"); // NOI18N

        sCedula.setName("sCedula"); // NOI18N

        jLabel8.setText("Estado Civil:");
        jLabel8.setName("jLabel8"); // NOI18N

        sEdoCivil.setName("sEdoCivil"); // NOI18N
        sEdoCivil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sEdoCivilActionPerformed(evt);
            }
        });

        jLabel12.setText("Sexo:");
        jLabel12.setName("jLabel12"); // NOI18N

        sSexo.setName("sSexo"); // NOI18N

        jLabel13.setText("Fecha Nacimiento:");
        jLabel13.setName("jLabel13"); // NOI18N

        sFecha.setName("sFecha"); // NOI18N

        jLabel9.setText("Nacionalidad:");
        jLabel9.setName("jLabel9"); // NOI18N

        sNacionalidad.setName("sNacionalidad"); // NOI18N

        jLabel11.setText("Usuario:");
        jLabel11.setName("jLabel11"); // NOI18N

        sUserName.setName("sUserName"); // NOI18N

        jLabel10.setText("Clave:");
        jLabel10.setName("jLabel10"); // NOI18N

        sPassword.setName("sPassword"); // NOI18N

        jLabel7.setText("Numero Reservas:");
        jLabel7.setName("jLabel7"); // NOI18N

        sNumReservas.setName("sNumReservas"); // NOI18N

        jLtipoCliente.setText("Tipo Cliente:");
        jLtipoCliente.setName("jLtipoCliente"); // NOI18N

        sTipoCliente.setName("sTipoCliente"); // NOI18N

        jLabel15.setText("Modificar o Eliminar:");
        jLabel15.setName("jLabel15"); // NOI18N

        jButton1.setText("Actualizar");
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Eliminar");
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLnombre1)
                            .addComponent(jLapellido1)
                            .addComponent(jLCedula)
                            .addComponent(jLabel8)
                            .addComponent(jLabel12)
                            .addComponent(jLabel13)
                            .addComponent(jLabel9)
                            .addComponent(jLabel11)
                            .addComponent(jLabel10)
                            .addComponent(jLabel7)
                            .addComponent(jLtipoCliente))
                        .addGap(80, 80, 80))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addContainerGap(116, Short.MAX_VALUE)
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButton1)
                        .addGap(48, 48, 48)))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(sPassword, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(sFecha, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(sSexo, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(sNombre, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)
                            .addComponent(sApellido, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(sCedula, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
                            .addComponent(sUserName, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(sNacionalidad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
                            .addComponent(sNumReservas, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(sTipoCliente, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)
                            .addComponent(sEdoCivil, javax.swing.GroupLayout.Alignment.LEADING))
                        .addContainerGap(24, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(72, 72, 72))))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLnombre1)
                            .addComponent(sNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLapellido1)
                            .addComponent(sApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(8, 8, 8)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLCedula)
                            .addComponent(sCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(sEdoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addGap(5, 5, 5)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(sSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel15)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(sFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sNumReservas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sTipoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLtipoCliente))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addGap(24, 24, 24))
        );

        jTabbedPane1.addTab("Modificar o Eliminar", jPanel2);

        jPanel1.setBackground(new java.awt.Color(0, 102, 153));
        jPanel1.setName("jPanel1"); // NOI18N

        jLnombre.setText("Nombre:");
        jLnombre.setName("jLnombre"); // NOI18N

        nNombre.setName("nNombre"); // NOI18N

        jLapellido.setText("Apellido:");
        jLapellido.setName("jLapellido"); // NOI18N

        nApellido.setName("nApellido"); // NOI18N

        jLabel1.setText("Cedula:");
        jLabel1.setName("jLabel1"); // NOI18N

        nCedula.setName("nCedula"); // NOI18N

        jLabel2.setText("Estado Civil:");
        jLabel2.setName("jLabel2"); // NOI18N

        nEdoCivil.setName("nEdoCivil"); // NOI18N
        nEdoCivil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nEdoCivilActionPerformed(evt);
            }
        });

        jLabel6.setText("Sexo:");
        jLabel6.setName("jLabel6"); // NOI18N

        nSexo.setName("nSexo"); // NOI18N

        jLabel14.setText("Fecha Nacimiento:");
        jLabel14.setName("jLabel14"); // NOI18N

        nFecha.setName("nFecha"); // NOI18N

        jLabel3.setText("Nacionalidad:");
        jLabel3.setName("jLabel3"); // NOI18N

        nNacionalidad.setName("nNacionalidad"); // NOI18N

        jLabel5.setText("Usuario:");
        jLabel5.setName("jLabel5"); // NOI18N

        nUserName.setName("nUserName"); // NOI18N

        jLabel4.setText("Clave:");
        jLabel4.setName("jLabel4"); // NOI18N

        nPassword.setName("nPassword"); // NOI18N

        jLtitulo.setText("Agregar Nuevo Usuario:");
        jLtitulo.setName("jLtitulo"); // NOI18N

        jButton3.setText("Agregar");
        jButton3.setName("jButton3"); // NOI18N
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(36, 36, 36)
                        .addComponent(jLabel1)
                        .addGap(88, 88, 88)
                        .addComponent(nCedula, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addComponent(jLnombre)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLtitulo)
                                .addGap(77, 77, 77))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(88, 88, 88)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(nApellido, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                                    .addComponent(nNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLapellido)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel14)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel3))
                                .addGap(41, 41, 41)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(nUserName, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                                    .addComponent(nPassword, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                                    .addComponent(nNacionalidad, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                                    .addComponent(nFecha, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                                    .addComponent(nSexo, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                                    .addComponent(nEdoCivil, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE))))))
                .addGap(131, 131, 131))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(119, 119, 119)
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(255, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLtitulo)
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLnombre)
                    .addComponent(nNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLapellido)
                    .addComponent(nApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nEdoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel14)
                    .addComponent(nFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addComponent(jLabel5))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(nUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(43, 43, 43)
                .addComponent(jButton3)
                .addGap(32, 32, 32))
        );

        jTabbedPane1.addTab("Agregar Nuevo Usuario", jPanel1);

        jLabel16.setFont(new java.awt.Font("Trebuchet MS", 0, 36));
        jLabel16.setForeground(new java.awt.Color(0, 51, 204));
        jLabel16.setText("i-Resort.");
        jLabel16.setName("jLabel16"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 551, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 466, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 389, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 395, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
ComunicaCliente comunicameACliente = new ComunicaCliente ();
        boolean resultado = false;
        String tipoCliente = "";
        String cedula = this.sCedula.getText();
        String nombre = this.sNombre.getText();
        String apellido = this.sApellido.getText();
        String sexo = this.sSexo.getText();
        String nacionalidad = this.sNacionalidad.getText();
        String edoCivil= this.sEdoCivil.getText();
        String userName = this.sUserName.getText();
        String Password = (String) this.sPassword.getText();
        SimpleDateFormat fechaFormato = new SimpleDateFormat("dd/MM/yyyy");
        Date lafecha = this.sFecha.getDate();
        String fecha = fechaFormato.format(lafecha);
        if(this.sTipoCliente.getText().equalsIgnoreCase("Estrella") == false)
            tipoCliente = comunicameACliente.enviarTipoCliente(fecha);
        else
            tipoCliente = this.sTipoCliente.getText();
        Integer numReservas = Integer.parseInt(this.sNumReservas.getText());
        resultado = this.control.actualizarCliente(cedula, nombre, apellido, sexo, nacionalidad, edoCivil, userName, Password, fecha,numReservas,tipoCliente);
        if (resultado) {
            JOptionPane.showMessageDialog(null, "Cliente " + nombre + " actualizado con exito", "Actualizado",
                    JOptionPane.INFORMATION_MESSAGE);
            this.mostrarTabla();
        } else {
            JOptionPane.showMessageDialog(null, "Operacion Fallida", "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jButton1ActionPerformed

      private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
          boolean resultado = this.control.eliminarCliente(this.sCedula.getText());
        if (resultado) {
            JOptionPane.showMessageDialog(null, "Cliente " + this.sNombre.getText() + " borrado con exito", "Borrado",
                    JOptionPane.INFORMATION_MESSAGE);
            this.mostrarTabla();
        } else {
            JOptionPane.showMessageDialog(null, "Operacion Fallida", "Error",
                    JOptionPane.ERROR_MESSAGE);
        } // TODO add your handling code here:
      }//GEN-LAST:event_jButton2ActionPerformed

      private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
          boolean resultado = false;
        String cedula = this.nCedula.getText();
        String nombre = this.nNombre.getText();
        String apellido = this.nApellido.getText();
        String sexo = this.nSexo.getText();
        String nacionalidad = this.nNacionalidad.getText();
        String edoCivil= this.nEdoCivil.getText();
        String userName = this.nUserName.getText();
        String Password = (String) this.nPassword.getText();
        SimpleDateFormat fechaFormato = new SimpleDateFormat("dd/MM/yyyy");
        Date lafecha = this.nFecha.getDate();
        String fecha = fechaFormato.format(lafecha);
         if (GestionResort.getLosClientes().BuscarClientePorCedula(cedula)== false)
         {
          if (menor_edad (fecha)==true)
          {
           resultado = this.control.nuevoCliente(cedula, nombre, apellido, sexo, nacionalidad, edoCivil, userName, Password, fecha);
        if (resultado) {
            JOptionPane.showMessageDialog(null, "Cliente " + nombre + " agregado con exito", "Agregado",
                    JOptionPane.INFORMATION_MESSAGE);
            this.mostrarTabla();
        } else {
            JOptionPane.showMessageDialog(null, "Operacion Fallida", "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
      }
          else
            JOptionPane.showMessageDialog(null, "Eres menor de edad", "Error",
                    JOptionPane.ERROR_MESSAGE);
     }
         else
               JOptionPane.showMessageDialog(null, "Operacion Fallida el Cliente con esta cedula se encuentra registrado ", "Error",
                    JOptionPane.ERROR_MESSAGE);
          // TODO add your handling code here:
      }//GEN-LAST:event_jButton3ActionPerformed

      private void tablaClientesMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaClientesMouseReleased
       int row = this.tablaClientes.getSelectedRow();
        String cedula = (String) this.tablaClientes.getModel().getValueAt(row, 2);
        try {
            this.mostrarCliente(cedula);
        } catch (ParseException ex) {
            Logger.getLogger(VentanaOperacionesCliente.class.getName()).log(Level.SEVERE, null, ex);
        }   // TODO add your handling code here:
      }//GEN-LAST:event_tablaClientesMouseReleased

      private void tablaClientesKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tablaClientesKeyReleased
       int row = this.tablaClientes.getSelectedRow();
        String cedula = (String) this.tablaClientes.getModel().getValueAt(row, 2);
        try {
            this.mostrarCliente(cedula);
        } catch (ParseException ex) {
            Logger.getLogger(VentanaOperacionesCliente.class.getName()).log(Level.SEVERE, null, ex);
        }   // TODO add your handling code here:
      }//GEN-LAST:event_tablaClientesKeyReleased

      private void nEdoCivilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nEdoCivilActionPerformed
          // TODO add your handling code here:
      }//GEN-LAST:event_nEdoCivilActionPerformed

      private void sEdoCivilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sEdoCivilActionPerformed
          // TODO add your handling code here:
      }//GEN-LAST:event_sEdoCivilActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VentanaOperacionesCliente().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLCedula;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLapellido;
    private javax.swing.JLabel jLapellido1;
    private javax.swing.JLabel jLnombre;
    private javax.swing.JLabel jLnombre1;
    private javax.swing.JLabel jLtipoCliente;
    private javax.swing.JLabel jLtitulo;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField nApellido;
    private javax.swing.JTextField nCedula;
    private javax.swing.JTextField nEdoCivil;
    private com.toedter.calendar.JDateChooser nFecha;
    private javax.swing.JTextField nNacionalidad;
    private javax.swing.JTextField nNombre;
    private javax.swing.JPasswordField nPassword;
    private javax.swing.JTextField nSexo;
    private javax.swing.JTextField nUserName;
    private javax.swing.JTextField sApellido;
    private javax.swing.JTextField sCedula;
    private javax.swing.JTextField sEdoCivil;
    private com.toedter.calendar.JDateChooser sFecha;
    private javax.swing.JTextField sNacionalidad;
    private javax.swing.JTextField sNombre;
    private javax.swing.JTextField sNumReservas;
    private javax.swing.JTextField sPassword;
    private javax.swing.JTextField sSexo;
    private javax.swing.JTextField sTipoCliente;
    private javax.swing.JTextField sUserName;
    private javax.swing.JTable tablaClientes;
    // End of variables declaration//GEN-END:variables

}
